class Dep {
  constructor() {
    this.subscribers = new Set();
  }

  addEffect(executor) {
    this.subscribers.add(executor);
  }

  notify() {
    this.subscribers.forEach((item) => {
      debugger;
      item();
    });
  }
}

let dep = new Dep();
function watchEffect(fn) {
  dep.addEffect(fn);
}

let info = {
  id: 1,
};
watchEffect(function () {
  debugger;
  console.log(info.id * 2);
});

info.id++;
dep.notify();
